package com.yunbiao.ybbusstopplate.base

import android.os.Bundle
import android.view.Window
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import com.yunbiao.ybbusstopplate.utils.ActivityUtils

abstract class BaseActivity : AppCompatActivity(){

    companion object{
        var onBackKeyListener:OnBackKeyListener?=null
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN)
        setContentView(getLayoutViewId())
        ActivityUtils.getInstance().addAty(this)
        initData()
    }

    abstract fun getLayoutViewId():Int

    abstract fun initData()

//    override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
//        if (keyCode==KeyEvent.KEYCODE_BACK){//返回键
//            if (onBackKeyListener!=null){
//                onBackKeyListener!!.onBack()
//                return false
//            }
//        }
//        return super.onKeyDown(keyCode, event)
//    }

    override fun onDestroy() {
        ActivityUtils.getInstance().removeAty(this)
        super.onDestroy()
    }

    interface OnBackKeyListener{
        fun onBack()
    }
}